<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/pages/template/general.xhtml">
	
	<ui:define name="content">
		<div class="pageHeader">Mala Direta</div>
		
		<h:form id="addForm">
			<p:growl autoUpdate="true" showDetail="true" />
			
			<h:outputText value="Remetente: " />
			<h:outputText value="#{mailBean.usuarioBean.usuario.email}" style="font-weight: bold;" /><br /><br />
			
			<h:outputText value="Senha do e-mail" /><br />
			<p:inputText type="password" value="#{mailBean.senha}" required="true" requiredMessage="Campo senha do e-mail vazio." /><br /><br />
			
			<h:outputText value="Destinatários (servidores cadastrados de #{mailBean.usuarioBean.chefeSetor.descricao})" /><br />
			<p:panel style="max-height: 140px; overflow: auto;">
				<p:selectManyCheckbox value="#{mailBean.destinatarios}" layout="pageDirection" required="true" requiredMessage="Nenhum destinatário foi selecionado.">
		            <f:selectItems value="#{mailBean.servidoresSetor}" var="servidor" itemLabel="#{servidor.nome} - #{servidor.email}" itemValue="#{servidor.email}" />
		        </p:selectManyCheckbox>
	        </p:panel>
	        <br />
	        
			<h:outputText value="Assunto" /><br />
			<p:inputText value="#{mailBean.assunto}" required="true" requiredMessage="Campo assunto vazio." style="width: 100%;" /><br /><br />
			
			<h:outputText value="Corpo da mensagem" /><br />
			<p:editor height="500" value="#{mailBean.corpoMensagem}" required="true" requiredMessage="Campo corpo da mensagem vazio." /><br /><br />
			
			<p:commandButton type="submit" value="Enviar" actionListener="#{mailBean.enviar}" update="@form" />
		</h:form>
		
		<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();" />
		
		<p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" style="padding: 40px 80px 60px 80px; text-align: center;">
			<f:facet name="header">&nbsp;</f:facet>
			<h:graphicImage library="images" name="progress.gif" /><br />
			<h:outputText value="Aguarde..." />
		</p:dialog>
	</ui:define>
	
</ui:composition>